package com.read.controller;

import com.read.resp.BaseResp;
import com.read.service.BookChapterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName DetailController
 * @Description TODO
 * @Author young
 * @Date 2022-11-05 14:35
 * @Version 1.0
 **/
@Api(tags = "章节查询接口")
@RequestMapping("/chapter")
@RestController
//该注解含义: 当配置文件更改后,本地也会动态刷新配置文件内容
@RefreshScope
public class BookChapterController {

    @Autowired
    BookChapterService bookChapterService;

    @ApiOperation(value = "查询图书章节名称列表")
    @RequestMapping("/findChaptersByBookId")
    public BaseResp findChaptersByBookId(String bookId){
        return bookChapterService.findChaptersByBookId(bookId);
    }

    @ApiOperation(value = "根据章节id,查询章节详细内容")
    @RequestMapping("/findContentByBookId")
    public BaseResp findContentByBookId(String bookId, Integer id, HttpServletRequest request){
        return bookChapterService.findContentByBookId(bookId,id,request);
    }

    @ApiOperation(value = "查询上一章内容")
    @RequestMapping("/findPreContentById")
    public BaseResp findPreContentById(String bookId, Integer id, HttpServletRequest request){
        return bookChapterService.findPreContentById(bookId,id,request);
    }

    @ApiOperation(value = "查询下一章内容")
    @RequestMapping("/findNextContentById")
    public BaseResp findNextContentById(String bookId, Integer id, HttpServletRequest request){
        return bookChapterService.findNextContentById(bookId,id,request);
    }



}
